/* OPTIONS OBS=10000 NOREPLACE; */

/* Construct a dataset of 6-digit NAICS industry cost shares
   for the FHS industries. */

/*include libraries for this project; */

%include "ASMimplibs.sas";


/* Read in aggregate input costs for labor, intermediates and energy, and 
   aggregate real stocks of capital from NBER-CES Productivity Database. 
   (6-digit NAICS level). */

/* NAICS 327320 = ready-mix concrete. */
data nberces_fhs (keep = NAICS NAICS3 YEAR PAY MATCOST ENERGY EQUIP PLANT);
 set nberces.naics5809;
 if year ge 2002 and year le 2007;
 naics_char = put(NAICS,z6.);
 NAICS3 = substr(naics_char,1,3);
 if NAICS3 = '312' then NAICS3 = '311'; /* Need to do this because BEA and BLS capital data aggregate 311 and 312. */
run;

proc contents data=nberces_FHS; run;


/* Read in BLS capital data for FHS industries and merge with nberces data: */

data BLS_capital;
 set bls.BLS_capital_FHS;
 if year ge 2002 and year le 2007;
run;

proc contents data=BLS_capital; run;

proc sort data=BLS_capital; by NAICS3 year; run;
proc sort data=nberces_FHS; by NAICS3 year; run;

data cost_shares_FHS (keep = NAICS NAICS3 YEAR iake iaks ial iam iae);
 merge BLS_capital nberces_FHS;
 by NAICS3 year;
 tc = eqrkl_base97*EQUIP + strkl_base97*PLANT + PAY + MATCOST;
 iake = eqrkl_base97*EQUIP/tc;
 iaks = strkl_base97*PLANT/tc;
 ial = PAY/tc;
 iam = (MATCOST - ENERGY)/tc;
 iae = ENERGY/tc;
run;

proc datasets library=work;
 modify cost_shares_FHS;
  label iake = 'Industry Average Cost Share, Capital Equipment';
  label iaks = 'Industry Average Cost Share, Capital Structures';
  label ial = 'Industry Average Cost Share, Labor';
  label iam = 'Industry Average Cost Share, Materials';
  label iae = 'Industry Average Cost Share, Energy';
run;

data indcs.cost_shares_FHS;
 set cost_shares_FHS;
run;

proc print data=indcs.cost_shares_FHS;
title1 "Industry Cost Shares, FHS industries";
run;